﻿@{
    ViewBag.Title = "机构管理";
    Layout = "~/Views/Shared/_Form.cshtml";
}
<script>
    var keyValue = request('keyValue');
    var parentId = request('parentId');
    $(function () {
        initControl();
    })
    //初始化控件
    function initControl() {
        //上级公司
        $("#F_ParentId").ComboBoxTree({
            url: "../../BaseManage/Organize/GetTreeJson",
            description: "==请选择==",
            height: "260px",
            allowSearch: true
        });
        //公司性质
        $("#F_Nature").ComboBox({
            url: "../../SystemManage/DataItemDetail/GetDataItemListJson",
            param: { EnCode: "CompanyNature" },
            id: "F_ItemValue",
            text: "F_ItemName",
            description: "==请选择==",
            height: "200px"
        });
        //负责人
        $("#F_ManagerId").ComboBoxTree({
            url: "../../BaseManage/User/GetTreeJson",
            description: "==请选择==",
            height: "220px",
            allowSearch: true
        });
        //省份
        $("#F_ProvinceId").ComboBox({
            url: "../../SystemManage/Area/GetAreaListJson",
            param: { parentId: "0" },
            id: "F_AreaCode",
            text: "F_AreaName",
            description: "选择省",
            height: "170px"
        }).bind("change", function () {
            var value = $(this).attr('data-value');
            $("#F_CityId").ComboBox({
                url: "../../SystemManage/Area/GetAreaListJson",
                param: { parentId: value },
                id: "F_AreaCode",
                text: "F_AreaName",
                description: "选择市",
                height: "170px"
            });
        });
        //城市
        $("#F_CityId").ComboBox({
            description: "选择市",
            height: "170px"
        }).bind("change", function () {
            var value = $(this).attr('data-value');
            if (value) {
                $("#F_CountyId").ComboBox({
                    url: "../../SystemManage/Area/GetAreaListJson",
                    param: { parentId: value },
                    id: "F_AreaCode",
                    text: "F_AreaName",
                    description: "选择县/区",
                    height: "170px"
                });
            }
        });
        //县/区
        $("#F_CountyId").ComboBox({
            description: "选择县/区",
            height: "170px"
        });
        //获取表单
        if (!!keyValue) {
            $.SetForm({
                url: "../../BaseManage/Organize/GetFormJson",
                param: { keyValue: keyValue },
                success: function (data) {
                    $("#form1").SetWebControls(data);
                    $("#F_FoundedTime").val(formatDate(data.F_FoundedTime, "yyyy-MM-dd"));
                    $("#F_ProvinceId").trigger("change");
                    if (data.F_CityId != undefined)
                    {
                        $("#F_CityId").ComboBoxSetValue(data.F_CityId).trigger("change");
                        $("#F_CountyId").ComboBoxSetValue(data.F_CountyId);
                    }
                  
                }
            });
        } else {
            $("#F_ParentId").ComboBoxTreeSetValue(parentId);
        }
    }
    //保存表单
    function AcceptClick() {
        if (!$('#form1').Validform()) {
            return false;
        }
        var postData = $("#form1").GetWebControls(keyValue);
        postData["F_Manager"] = $("#F_ManagerId").attr('data-text');
        if (postData["F_ParentId"] == "") {
            postData["F_ParentId"] = 0;
        }
        $.SaveForm({
            url: "../../BaseManage/Organize/SaveForm?keyValue=" + keyValue,
            param: postData,
            loading: "正在保存数据...",
            success: function () {
                $.currentIframe().$("#gridTable").resetSelection();
                $.currentIframe().$("#gridTable").trigger("reloadGrid");
            }
        })
    }
</script>
<div style="margin-left: 10px; margin-top: 20px; margin-right: 30px;">
    <table class="form">
        <tr>
            <th class="formTitle">公司名称<font face="宋体">*</font></th>
            <td class="formValue">
                <input id="F_FullName" type="text" onblur="$.ExistField(this.id,'../../BaseManage/Organize/ExistFullName')" class="form-control" isvalid="yes" checkexpession="NotNull" />
            </td>
            <th class="formTitle">公司性质<font face="宋体">*</font></th>
            <td class="formValue">
                <div id="F_Nature" type="select" class="ui-select" isvalid="yes" checkexpession="NotNull"></div>
            </td>
        </tr>
        <tr>
            <th class="formTitle">外文名称<font face="宋体">*</font></th>
            <td class="formValue">
                <input id="F_EnCode" type="text" onblur="$.ExistField(this.id,'../../BaseManage/Organize/ExistEnCode')" class="form-control" isvalid="yes" checkexpession="NotNull"/>
            </td>
            <th class="formTitle">中文名称<font face="宋体">*</font></th>
            <td class="formValue">
                <input id="F_ShortName" type="text" onblur="$.ExistField(this.id,'../../BaseManage/Organize/ExistShortName')" class="form-control" isvalid="yes" checkexpession="NotNull"/>
            </td>
        </tr>
        <tr>
            <th class="formTitle">上级公司</th>
            <td class="formValue">
                <div id="F_ParentId" type="selectTree" class="ui-select">
                </div>
            </td>
            <th class="formTitle">成立时间</th>
            <td class="formValue">
                <input id="F_FoundedTime" type="text" class="form-control input-wdatepicker" onfocus="WdatePicker()" />
            </td>
        </tr>
        <tr>
            <th class="formTitle">负责人</th>
            <td class="formValue">
                <div id="F_ManagerId" type="selectTree" class="ui-select"></div>
            </td>
            <th class="formTitle">电话</th>
            <td class="formValue">
                <input id="F_OuterPhone" type="text" class="form-control" />
            </td>

        </tr>
        <tr>
            <th class="formTitle">电子邮箱</th>
            <td class="formValue">
                <input id="F_Email" type="text" class="form-control" />
            </td>
            <th class="formTitle">传真</th>
            <td class="formValue">
                <input id="F_Fax" type="text" class="form-control" />
            </td>
        </tr>

        <tr>
            <th class="formTitle">公司地点</th>
            <td class="formValue" colspan="3">
                <div style="float: left; width: 255px;">
                    <div id="F_ProvinceId" type="select" class="ui-select" style="float: left; width: 84px; margin-right: 1px;"></div>
                    <div id="F_CityId" type="select" class="ui-select" style="float: left; width: 84px; margin-right: 1px;"></div>
                    <div id="F_CountyId" type="select" class="ui-select" style="float: left; width: 84px; margin-right: 1px;"></div>
                </div>
                <div style="margin: 0 auto; width: 100%;">
                    <input id="F_Address" type="text" class="form-control" style="float: left; width: 354px;" />
                </div>
            </td>
        </tr>
        <tr>
            <th class="formTitle">邮编</th>
            <td class="formValue">
                <input id="F_Postalcode" type="text" class="form-control" />
            </td>
            <th class="formTitle">公司官网</th>
            <td class="formValue">
                <input id="F_WebAddress" type="text" class="form-control" />
            </td>
        </tr>
        <tr>
            <th class="formTitle">经营范围
            </th>
            <td class="formValue" colspan="3">
                <input id="F_BusinessScope" type="text" class="form-control" />
            </td>
        </tr>
        <tr>
            <th class="formTitle" valign="top" style="padding-top: 4px;">备注
            </th>
            <td class="formValue" colspan="3">
                <textarea id="F_Description" class="form-control" style="height: 70px;"></textarea>
            </td>
        </tr>
    </table>
</div>
